# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Gabriel Martinez < reitaka at gmail dot com >

pkgname=libimobiledevice
pkgver=1.3.0
pkgrel=9
pkgdesc='Library to communicate with services on iOS devices using native protocols'
arch=('loong64' 'x86_64')
url='https://libimobiledevice.org/'
license=('LGPL2.1')
depends=('glibc' 'libplist' 'libusbmuxd' 'openssl')
makedepends=('cython' 'python')
optdepends=('python: Python bindings')
source=("https://github.com/libimobiledevice/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.bz2"
        'libimobiledevice-libplist-2.3.0.patch')
sha256sums=('53f2640c6365cd9f302a6248f531822dc94a6cced3f17128d4479a77bd75b0f6'
            '57fb4616c68c240aad47df52168fa30e4bf43845bfbe53df23cc412003ae64fd')

prepare() {
  cd $pkgname-$pkgver
  # Fix build with libplist 2.3.0
  patch -Np1 -i ../libimobiledevice-libplist-2.3.0.patch
  autoreconf -fi
}

build() (
  cd $pkgname-$pkgver
  ./configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
)

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  # Include documentation
  install -dm755 "$pkgdir/usr/share/doc/$pkgname"
  cp -r docs/html "$pkgdir/usr/share/doc/$pkgname/"
}
